package com.neutch.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class sjxm_2 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
//        加载驱动类
        Class.forName("com.mysql.cj.jdbc.Driver");
        //连接准备工作

        String url = "jdbc:mysql://localhost:3306/test";

        //获取连接
        Connection conn= DriverManager.getConnection(url,"root","123456");

        //执行SQL
        String sql="select * from users";
        ResultSet res;
        Statement sta=conn.createStatement();
        res=sta.executeQuery(sql);
        while(res.next()){
            System.out.println(res.getString(1));
        }

        //使用DAO层封装完成第一题

    }
}
